/**
 * v-scrollToBottom
 * 滚动
 */
import type { Directive, DirectiveBinding } from 'vue'
import { nextTick } from 'vue'
const scrollToBottom: Directive = {
  mounted(el: any, binding: DirectiveBinding) {
    nextTick(() => {
      // 获取容器和内容
      let container = el.parentNode.parentNode.parentNode
      let content = el.parentNode.parentNode

      // 自动滚动到底部函数
      function scrollToBottom() {
        // 确保滚动到容器的底部
        container.scrollTop = container.scrollHeight - container.clientHeight
      }

      scrollToBottom()
    })
  }
}

export default scrollToBottom
